<!doctype html>
<html>
<head>
   <meta charset="utf-8">
   <title>后台登录 - 内容管理系统</title>
   <link rel="stylesheet" href="/static/admin/css/dashicons.css">
   <link rel="stylesheet" href="/static/admin/css/layout.css">
   <script src="/static/index/js/jquery.2.1.4.min.js"></script>
   <script>
      if (top.location !== self.location) {
         top.location = self.location;
      }
   </script>
</head>

<body>
   <div class="top">
      <div class="top-title icon-home">内容管理系统</div>
      <div class="top-right">
         <a href="../" target="_blank">前台首页</a>
      </div>
   </div>
   <div class="login">
      <div class="login-wrap">
         <a href="../" target="_blank" class="login-logo" title="点击查看前台首页"></a>
         <div class="tips"></div>
         <div class="login-box">
<!--            <form method="post" action=" {:url('register')}">-->
               <table>
                  <tr>
                     <th>账 号：</th>
                     <td><input type="text" name="nickname" value="" autocomplete="off"></td>
                  </tr>
                  <tr>
                     <th>昵　称：</th>
                     <td><input type="text" name="username" value="" autocomplete="off"></td>
                  </tr>
                  <tr>
                     <th>密　码：</th>
                     <td><input type="password" name="password" autocomplete="off"></td>

                  </tr>
                  <tr>
                     <th></th>
                     <td><input type="submit" onclick="add()" value="注册"></td>
                  </tr>
               </table>
<!--            </form>-->
         </div>
      </div>
   </div>
   <script>
      //验证码点击刷新
      (function () {
         var $img = $("#captcha");
         var src = $img.attr("src") + "?_=";
         $img.click(function () {
            $img.attr("src", src + Math.random()); //添加随机数防止浏览器缓存图片
         });
      })();
   </script>
</body>
<script>
   function add(){
      $.ajax({
         url:'register',
         type:'POST',
         data:{
            nickname:$("input[name=nickname]").val(),//账 号
            username:$("input[name=username]").val(),//昵称
            password:$("input[name=password]").val(),
         },
         success:function (res){
           if(res.code == 0){
              alert(res.msg);
           }else{
              alert(res.msg);
              setTimeout(()=>{
                 window.location='http://www.tp6cms.com/index.php/home/index/login';
              },100);
           }
         }
      })
   }

</script>
</html>